package thread;

/**
 * 守护线程测试
 *
 * @author dingwen
 * @date 2021/09/05
 */
public class DaemonThreadTest {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();
        Thread thread1 = new Thread(god);

        // 设置为守护线程
        thread1.setDaemon(true);
        thread1.start();

        new Thread(you).start();
    }
}


class God implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("上帝保佑你");
        }
    }
}


class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("你开心都度过了第" + i + "天");
        }
        System.out.println("byte");
    }
}